import instacne from "../request";
import type { Ref } from "vue";

// /productCategory/list/{parentId}
// 分页查询商品分类
interface productCateParams {
  parentId: number;
  pageNum?: number;
  pageSize?: number;
}
interface productCatelist {
  description: string;
  icon: string;
  id: number;
  keywords: string;
  level: number;
  name: string;
  navStatus: number;
  parentId: number;
  productCount: number;
  productUnit: string;
  showStatus: number;
  sort: number;
}
interface productCateRes {
  list: productCatelist[];
  pageNum: number;
  pageSize: number;
  total: number;
  totalPage: number;
}

const adminproductCate = (data: productCateParams): Promise<productCateRes> => {
  return instacne.get(`/productCategory/list/${data.parentId}`, {
    params: data,
  });
};

// /productCategory/list/withChildren
// 查询所有一级分类及子分类
// const adminproductCateClidrn=():

// productCategory/delete/{id}
// 删除商品分类
interface ProductCategory {
  id: number;
}
const deleteproductCate = (id: ProductCategory) => {
  return instacne.post(`/productCategory/delete/${id}`);
};

// 添加商品

export { adminproductCate, deleteproductCate };
export type { productCatelist, productCateRes, productCateParams };
